﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using CodeContrib;
using CodeContrib.Data.Entity;

namespace CodeContribBlog.Data
{
	[MetadataType(typeof (TagMetadata))]
	public class Tag : Entity
	{
		private string _name;
		private string _slug;

		public Blog Blog { get; set; }

		public string Name
		{
			get { return _name; }
			set
			{
				_name = value;

				Slug = _name;
			}
		}

		public virtual ICollection<Post> Posts { get; set; }

		public string Slug
		{
			get { return _slug; }
			set { _slug = value.ToSlug(); }
		}
	}
}